<template>
	<applyShortTable v-if="isCommitApply" :applyId="applyId" v-on:showShotPreview="showShotPreview"></applyShortTable>
	<accept-preview v-else-if="isShowAcceptPreview" :applyId="applyId"></accept-preview>
	<div v-else class="m-window" v-loading="loading" element-loading-text="数据加载中">
		<el-row class="applyShortPreview-col" type="flex">
			<el-col class="opts-col">
				<el-button type="primary" @click="confirmApply" style="width:120px;">确认</el-button>
			</el-col>
			<el-col :span="23" class="info-table-col">
				<span style="color:red;">
					温馨提示：1、融资日期只限工作日
					2、申请当天不能作为融资开始日（即放款日）
					3、融资到期日到当月25号，如25号非工作日，则提前至较近的工作日
				</span>
				<el-form :v-model="applyShortPreviewForm" ref="applyShortPreviewForm">
					<el-form-item>
						<table class="emphasis-table">
							<tr>
								<th>供应商</th>
								<td>{{applyShortPreviewForm.custName}}</td>
							</tr>
							<tr>
								<th>
									<div>
										<span style="color:red">*</span>
										<span>实际控制人</span>
									</div>
								</th>
								<td>
									<el-input
										placeholder="请输入实际控制人"
										v-model="applyShortPreviewForm.realController"
										maxlength="10"
										show-word-limit
										clearable
									></el-input>
								</td>
							</tr>
							<tr>
								<th>收款账户户名</th>
								<td>{{ familyName }}</td>
							</tr>
							<tr>
								<th>收款账户账号</th>
								<td>{{ bankNo }}</td>
							</tr>
							<tr>
								<th>收款账户开户行</th>
								<td>{{ bank }}</td>
							</tr>
							<tr>
								<th>微信</th>
								<td>{{ applyShortPreviewForm.custSrmWechat }}</td>
							</tr>
							<tr>
								<th>邮箱</th>
								<td>{{ applyShortPreviewForm.custSrmEmail }}</td>
							</tr>
							<tr>
								<th>可融金额（元）</th>
								<td>{{ getFormatMoney }}</td>
							</tr>
							<tr>
								<th>融资产品</th>
								<td>天进宝</td>
							</tr>
							<tr>
								<th>
									<div>
										<span style="color:red">*</span>
										<span>融资金额（元）</span>
									</div>
								</th>
								<td>
									<el-input
										v-model="applyShortPreviewForm.money"
										placeholder="输入金额"
										:readonly="moneyReaadOnly"
										@keyup.native="changeMoney"
										@blur="changeMoneyFormat"
									></el-input>
								</td>
							</tr>
							<tr>
								<th>融资金额大写</th>
								<td>{{ captainMoney }}</td>
							</tr>
							<tr>
								<th>服务费率（含税）</th>
								<td>{{ getRate }}</td>
							</tr>
							<tr>
								<th>
									<div>
										<span style="color:red">*</span>
										<span>融资开始日期</span>
									</div>
								</th>
								<td>
									<el-date-picker
										v-model="applyShortPreviewForm.applyDate"
										type="date"
										placeholder="选择日期"
										value-format="timestamp"
										:picker-options="pickerOptionsBegin"
										:readonly="moneyReaadOnly"
									></el-date-picker>
								</td>
							</tr>
							<tr>
								<th>
									<div>
										<span>融资到期日期</span>
									</div>
								</th>
								<td>
									<el-date-picker
										v-model="applyShortPreviewForm.prepaybackDate"
										type="date"
										placeholder="选择日期"
										value-format="timestamp"
										:picker-options="pickerOptionsEnd"
										:readonly="EndDateReadOnly"
									></el-date-picker>
								</td>
							</tr>
						</table>
					</el-form-item>
				</el-form>
			</el-col>
		</el-row>
		<el-dialog
			title="申请人联系方式"
			:visible.sync="custInfModel"
			v-dialogDrag
			:close-on-click-modal="false"
		>
			<h1 style="color:#bf1d1d; margin-bottom: 8px;">提示：贵司累计融资金额超过300万，需要线下评审，请填写贵司申请人和申请人手机！</h1>
			<el-form label-width="100px" :model="custInfForm" :rules="custInfRules" ref="custInfForm">
				<el-row>
					<el-col :span="24">
						<el-form-item label="申请人" prop="custName">
							<el-input v-model="custInfForm.custName" placeholder="请输入申请人姓名"></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="24">
						<el-form-item label="申请人手机" prop="custPhone">
							<el-input
								v-model="custInfForm.custPhone"
								placeholder="请输入申请人手机号码"
								@keyup.native="verifyRestrict"
								maxlength="11"
							></el-input>
						</el-form-item>
					</el-col>
				</el-row>
			</el-form>
			<span slot="footer" class="dialog-footer">
				<!-- 取消与关闭不需要弹窗 -->
				<el-button type="primary" @click="closeModel">取消</el-button>
				<el-button type="primary" @click="saveSuccess('custInfForm')">确认</el-button>
			</span>
		</el-dialog>
	</div>
</template>
<style lang="less" rel="stylesheet/less" scoped>
.applyShortPreview-col {
	flex-direction: column;
	height: 100%;
	.info-table-col {
		margin-top: 10px;
		flex: 1;
		overflow: auto;
	}
	.emphasis-table {
		width: 100%;
		margin-top: 10px;
		.hit {
			color: #409eff !important;
		}
		.font-underline {
			text-decoration: underline;
		}
		tr {
			&:nth-child(even) th,
			&:nth-child(even) td {
				background: #f9fafa;
			}
			td,
			th {
				border: 1px solid #eee;
				padding: 0 10px;
				height: 35px;
				line-height: 35px;
				text-align: right;
				width: 50%;
			}
			th {
				&:first-child {
					width: 10%;
					text-align: center;
				}
				&:last-child {
					width: 90%;
				}
			}
			td {
				text-align: left;
				& /deep/ .el-input__inner {
					border: none !important;
					outline-style: none !important;
					height: 35px;
					line-height: 35px;
					margin-left: -10px;
				}
				& /deep/ .el-input__prefix {
					left: -5px;
					top: -2px;
				}
			}
		}
	}
}
</style>
<script>
import applyShortTable from "./applyShortTable.vue";
import {
	regainOriginalMoneyFormat,
	formatPrice,
	formatRate,
	getSpecifyDate,
	switchCaptainMoney,
	formatPriceEdit,
} from "@/util/format.js";
import EmphasisTable from "@/components/emphasisTable.vue";
import { mapState, mapActions } from "vuex";
/**
 * @group financeManager
 * 天进宝确认申请
*/
export default {
    name:"applyShortPreview",
	props: {
        //从我的申请列表跳转
        applyListApplyId:{
            // 申请id
            type:String
        }
    },
	data () {
		return {
			loading: true,
			whitelist: [],
			blacklist: [],
			EndDate: "",
			bankNo: "",
			familyName: "",
			bank: "",
			captainMoney: "",
			applyId: "",
			custInfModel: false,
			moneyReaadOnly: false,
			EndDateReadOnly: true,
			custInf: this.$store.state.supplyChainFinance.custInf, //获取供应商信息
			isCommitApply: false,
			isShowAcceptPreview: false,
			applyShortPreviewForm: {
				money: null,
				applyDate: "",
				prepaybackDate: "", //this.getPaybackDate(25)
				realController: ''
			},
			availableAmount: 0,
			allRepayment: 0,
			customerRate: "",
			custInfForm: {
				custName: "",
				custPhone: "",
			},
			custInfRules: {
				custName: [
					{
						required: true,
						message: "请输入申请人姓名",
						trigger: "blur",
					},
					{
						min: 2,
						max: 10,
						message: "长度在 2 到 10 个字符",
						trigger: "blur",
					},
				],
				custPhone: [
					{
						required: true,
						message: "请输入申请人手机号码",
						trigger: "blur",
					},
					{
						validator: (rule, value, callback) => {
							let mobile = /^((13[0-9])|(14[5,7,9])|(15[0-3,5-9])|(17[0,3,5-8])|(18[0-9])|166|198|199|(147)){1}(\d){8}$/;
							if (!mobile.test(value)) {
								callback(new Error("请输入正确的手机号码"));
							} else {
								callback();
							}
						},
						trigger: "blur",
					},
				],
			},
		};
	},
	beforeMount () {
		let params = {
			supplierId: this.custInf.custId, //客户id
		};
		this.getAvailableAmount(params);
		this.getCustomerRate(params);
		this.getPrepaybackDate(25);
	},
	created () {
		this.applyShortPreviewForm.custSrmEmail = this.custInf.mail;
		this.applyShortPreviewForm.custSrmWechat = this.custInf.weChatNo;
		this.applyShortPreviewForm.custName = this.custInf.custName;
		this.applyId = this.applyListApplyId;
		this.getDays();
		this.getEsignAccountByCustId();
		if (this.applyId) {
			//获取申请主表信息
			this.$http
				.getApplyInfo({
					id: this.applyId,
				})
				.then(({ data }) => {
					if (data.code == 200) {
						let row = data.rows;
						let applyAmt = row.applyAmt ? row.applyAmt : 0;
						this.applyShortPreviewForm.money = formatPrice(applyAmt);
						this.captainMoney = switchCaptainMoney(applyAmt);
						this.applyShortPreviewForm.prepaybackDate = new Date(
							row.prepaybackDate
						).getTime();
						this.applyShortPreviewForm.applyDate = new Date(
							row.applyDate
						).getTime();
						this.applyShortPreviewForm.custSrmEmail = row.custSrmEmail
							? row.custSrmEmail
							: this.custInf.mail;
						this.applyShortPreviewForm.custSrmWechat = row.custSrmWechat
							? row.custSrmWechat
							: this.custInf.weChatNo;
						this.applyShortPreviewForm.realController = row.realController
					} else {
						this.$alert("获取申请表信息失败", {
							confirmButtonText: "确定",
							customClass: "alertFailure",
						});
					}
				})
				.catch((errror) => {
					this.$alert("查询主表信息失败，请检查网络", {
						confirmButtonText: "确定",
						customClass: "alertFailure",
					});
				});
		} else {
			this.applyShortPreviewForm.realController = this.$global.realController
		}
		// this.applyShortPreviewForm.prepaybackDate = this.getPaybackDate(25)
		// let dd = new Date(new Date().toLocaleDateString());
		//this.applyShortPreviewForm.applyDate = dd.setDate(dd.getDate() + 1);
	},
	methods: {
        ...mapActions(["changeFromPage"]),
        /**
         * @vuese
         * 正则验证手机号码
        */
		verifyRestrict () {
			this.custInfForm.custPhone = this.custInfForm.custPhone.replace(
				/[^\d]/g,
				""
			);
        },
        /**
         * @vuese
         * 对输入的申请金额进行格式化
        */
		changeMoneyFormat () {
			if (this.applyShortPreviewForm.money) {
				this.applyShortPreviewForm.money = this.applyShortPreviewForm.money.replace(
					/\.+$/,
					""
				);
				const nums = this.applyShortPreviewForm.money.toString().split(".");
				if (nums.length == 1) {
					this.applyShortPreviewForm.money =
						this.applyShortPreviewForm.money + ".00";
				} else if (nums[1].length == 1) {
					this.applyShortPreviewForm.money =
						this.applyShortPreviewForm.money + "0";
				}
				this.changeMoney();
			}
        },
        /**
         * @vuese
         * 获取放假日期数据
        */
		async getDays () {
			let that = this;
			await this.$http
				.getDays()
				.then(({ data }) => {
					if (data.code == 200 && data.rows) {
						that.whitelist = data.rows.workdays;
						that.blacklist = data.rows.holidays;
					} else {
						this.$alert(`获取数据失败：${data.info}`, {
							confirmButtonText: "确定",
							customClass: "alertFailure",
						});
					}
				})
				.catch((error) => {
					this.$alert("查询日期数据失败，请检查网络！", {
						confirmButtonText: "确定",
						customClass: "alertFailure",
					});
				});
        },
        /**
         * @vuese
         * 获取当前供应商电子签信息
        */
		async getEsignAccountByCustId () {
			let custId = this.supplyChainFinance.custInf.custId + "";
			let that = this;
			await this.$http
				.getEsignAccountByCustId({ custId: custId })
				.then(({ data }) => {
					setTimeout(() => {
						that.loading = false;
					}, 500);
					if (data.code == 200 && data.rows) {
						that.bankNo = data.rows.bank_no;
						var bankinfo = data.rows.sub_bank;
						bankinfo = bankinfo.replace(data.rows.bank, "");
						bankinfo = data.rows.bank + bankinfo;
						that.bank = bankinfo;
						that.familyName = data.rows.name;
					} else {
						this.$alert(`获取数据失败：${data.info}`, {
							confirmButtonText: "确定",
							customClass: "alertFailure",
						});
					}
				})
				.catch((error) => {
					this.loading = false;
					this.$alert("查询失败，请检查网络！", {
						confirmButtonText: "确定",
						customClass: "alertFailure",
					});
				});
        },
        /**
         * @vuese
         * 输入金额格式验证
        */
		changeMoney () {
			this.applyShortPreviewForm.money = this.applyShortPreviewForm.money.replace(
				/[^(\d|.)]/g,
				""
			); //只允许输入数字
			if (this.applyShortPreviewForm.money < 0.01) {
				this.captainMoney = "";
				return;
			}
			this.applyShortPreviewForm.money = this.applyShortPreviewForm.money.replace(
				/\.{2,}/g,
				"."
			); //只保留第一个. 清除多余的
			this.applyShortPreviewForm.money = this.applyShortPreviewForm.money
				.replace(".", "$#$")
				.replace(/\./g, "")
				.replace("$#$", ".");
			this.applyShortPreviewForm.money = this.applyShortPreviewForm.money.replace(
				/^(\-)*(\d+)\.(\d\d).*$/,
				"$1$2.$3"
			); //只能输入两个小数
			this.applyShortPreviewForm.money = formatPriceEdit(
				this.applyShortPreviewForm.money.toString().replace(/[,]/g, "")
			);
			let money = regainOriginalMoneyFormat(this.applyShortPreviewForm.money);
			this.captainMoney = money ? switchCaptainMoney(money) : "";
        },
        /**
         * @vuese
         * 确认保存融资申请
        */
		confirmApply () {
			//  if (this.applyId) {
			//     //提交界面点击返回，当该页面主表id存在，那么就不需要新增数据，直接跳转到提交申请页面
			//     this.isCommitApply = true;
			//     this.changeFromPage("applyShortPreview");
			//     return;
			//   }
			let money = regainOriginalMoneyFormat(this.applyShortPreviewForm.money);
			if (!money) {
				this.$alert("请输入融资金额", {
					confirmButtonText: "确定",
					customClass: "alertPrompt",
				});
				return;
			} else if (money <= 0) {
				this.$alert("融资金额必须大于0元", {
					confirmButtonText: "确定",
					customClass: "alertPrompt",
				});
				return;
			} else if (money > this.availableAmount) {
				this.$alert("融资金额不能大于可融金额", {
					confirmButtonText: "确定",
					customClass: "alertPrompt",
				});
				return;
			}
			let limitFromDate = this.getPaybackDate(5); //融资发起日最小日期
			let limitToDate = this.getPaybackDate(26); //融资到期日最大日期
			if (!this.applyShortPreviewForm.applyDate) {
				this.$alert("融资开始日期不能为空", {
					confirmButtonText: "确定",
					customClass: "alertPrompt",
				});
				return;
			} else if (this.applyShortPreviewForm.applyDate < limitFromDate) {
				this.$alert("融资开始日期：请选择本月5号至24号之间", {
					confirmButtonText: "确定",
					customClass: "alertPrompt",
				});
				return;
			}
			if (!this.applyShortPreviewForm.prepaybackDate) {
				this.$alert("融资到期日期不能为空", {
					confirmButtonText: "确定",
					customClass: "alertPrompt",
				});
				return;
			} else if (this.applyShortPreviewForm.prepaybackDate >= limitToDate) {
				this.$alert("融资到期日期：请选择本月25号之前", {
					confirmButtonText: "确定",
					customClass: "alertPrompt",
				});
				return;
			} else if (
				this.applyShortPreviewForm.prepaybackDate <
				this.applyShortPreviewForm.applyDate
			) {
				this.$alert("融资到期日期不能小于融资开始日期", {
					confirmButtonText: "确定",
					customClass: "alertPrompt",
				});
				return;
			} else if (!this.applyShortPreviewForm.realController) {
				this.$alert("实际控制人不能为空", {
					confirmButtonText: "确定",
					customClass: "alertPrompt"
				});
				return;
			}
			let prepaybackDate = new Date(
				this.applyShortPreviewForm.prepaybackDate
			).Format("yyyy-MM-dd 00:00:00");
			let params = {
				applyAmt: money, //申请融资金额
				applyDate: this.applyShortPreviewForm.applyDate, //融资开始日期
				prepaybackDate: new Date(prepaybackDate).getTime(), //融资到期日期
				finType: 0, //融资类别
				custId: this.custInf.custId, //客户id
				custName: this.custInf.custName, //客户名称
				availableAmt: this.availableAmount, //可融金额
				totalFinAmount: 0, //累积融资金额（含本次）
				realController: this.applyShortPreviewForm.realController
			};
			let that = this;
			//   if (money < 100000) {
			//       //累积融资金额300万以下，跳转到提交申请表界面
			//       that.saveApplyInf(params, function(data) {
			//         that.applyId = data.id;
			//         that.isCommitApply = true;
			//         that.isShowAcceptPreview = false;
			//         that.changeFromPage("applyShortPreview");
			//       });
			//     } else {
			//       //累积融资金额300万以上，弹出对接人信息输入框
			//       that.custInfModel = true;
			//     }
			that.getAllRepayment(function () {
				let sumNum = parseFloat(that.allRepayment) + parseFloat(money);
				params.totalFinAmount = sumNum;
				let maxAmount = 3000000;
				if (sumNum <= maxAmount) {
					//累积融资金额300万以下，跳转到提交申请表界面
					that.saveApplyInf(params, function (data) {
						that.applyId = data && data.id ? data.id : "";
						that.isCommitApply = true;
						that.isShowAcceptPreview = false;
						that.changeFromPage("applyShortPreview");
					});
				} else {
					//累积融资金额300万以上，弹出对接人信息输入框
					that.custInfModel = true;
				}
			});
		},
        /**
         * @vuese
         * 获取天进宝当前可融额度
         * @arg 参数params为Obj;代表接口请求参数
        */
		getAvailableAmount (params) {
			this.$http
				.getAvailableAmount(params)
				.then((response) => {
					if (response.data.code == 200) {
						this.availableAmount = response.data.rows.sumBorrowBalance
							? response.data.rows.sumBorrowBalance
							: 0.0;
					} else {
						this.availableAmount = 0;
					}
				})
				.catch((errror) => {
					this.$alert("查询可融金额失败，请检查网络！", {
						confirmButtonText: "确定",
						customClass: "alertFailure",
					});
				});
		},
		/**
         * @vuese
         * 获取当前客户服务利率
         * @arg 参数params为Obj;代表接口请求参数
        */
		getCustomerRate (params) {
			this.$http.getCustomerRate(params).then((response) => {
				if (response.data.code == 200) {
					this.customerRate = response.data.rows.rate
						? response.data.rows.rate
						: 0.0;
				} else {
					this.customerRate = 0;
				}
			});
		},
		/**
         * @vuese
         * 计算默认融资到期日期
         * @arg 参数n为默认最大融资到期日
        */
		getPrepaybackDate (n) {
			let dateFormat = this.$utils.dateFormat;
			let year = new Date().getFullYear();
			let month = new Date().getMonth();
			let currentDate = new Date().getDate();
			let date = new Date(year, month, n);

			if (
				!this.datePickerOptions(date, dateFormat("yyyy-MM-dd", date), false) &&
				currentDate < n
			) {
				this.$set(
					this.applyShortPreviewForm,
					"prepaybackDate",
					new Date(dateFormat("yyyy-MM-dd", date)).getTime()
				);
				this.EndDate = dateFormat("yyyy-MM-dd", date);
			} else {
				if (currentDate < n) {
					this.getPrepaybackDate(n - 1);
				} else {
					this.$set(this.applyShortPreviewForm, "prepaybackDate", "");
					//   let endDate=new Date('2020-04-24').getTime()
					//   this.$set(this.applyShortPreviewForm,'prepaybackDate',endDate);
					//   console.log('eeeee')
				}
			}
		},
        /**
         * @vuese
         * 获取客户累计未还款总金额
         * @arg 参数callback为接口返回成功后调用的回调函数
        */
		getAllRepayment (callback) {
			let that = this;
			let params = {
				custId: that.custInf.custId,
				applyId: this.applyId,
			};
			that.$http
				.getAllRepayment(params)
				.then((response) => {
					if (response.data.code == 200) {
						that.allRepayment = response.data.rows.allApplyAmt
							? response.data.rows.allApplyAmt
							: 0;
						callback();
					} else {
						that.$alert(response.data.info, {
							confirmButtonText: "确定",
							customClass: "alertFailure",
						});
						return;
					}
				})
				.catch((errror) => {
					that.$alert("获取客户累计未还款总金额失败，请检查网络！", {
						confirmButtonText: "确定",
						customClass: "alertFailure",
					});
				});
        },
        /**
         * @vuese
         * 返回到确认申请页面
         * @arg 参数val为申请id
        */
		showShotPreview (val) {
			this.isCommitApply = false;
			//this.moneyReaadOnly = true;
			this.applyId = val;
		},
        /**
         * @vuese
         * 确认保存主表信息
        */
		saveApplyInf (params, callback) {
			params.id = this.applyId;
			const gLoading = this.$loading({
				lock: true,
				text: "确认申请融资中，请稍等",
				spinner: "el-icon-loading",
				background: "rgba(255, 255, 255, .9)",
			});
			this.$http
				.confirmApply(params)
				.then((response) => {
					if (response.data.code == 200) {
						gLoading.text = "确认成功，正在跳转中...";
						setTimeout(() => {
							callback(response.data.rows);
							gLoading.close();
						}, 600);
					} else {
						gLoading.close();
						this.$alert(`确认申请融资失败：${response.data.info}`, {
							confirmButtonText: "确定",
							customClass: "alertFailure",
						});
					}
				})
				.catch((errror) => {
					gLoading.close();
					this.$alert(`确认申请融资失败，请检查网络！`, {
						confirmButtonText: "确定",
						customClass: "alertFailure",
					});
				});
        },
        /**
         * @vuese
         * 关闭线下申请弹窗
        */
		closeModel () {
			this.custInfModel = false;
        },
        /**
         * @vuese
         * 确认保存线下申请
         * @arg 参数formName为表单域名称
        */
		saveSuccess (formName) {
			this.$refs[formName].validate((valid) => {
				let money = regainOriginalMoneyFormat(this.applyShortPreviewForm.money);
				let sumNum = parseFloat(this.allRepayment) + parseFloat(money);
				if (valid) {
					this.$confirm("是否确认提交？")
						.then(() => {
							let params = {
								applyAmt: money, //申请融资金额
								finType: 0, //融资类别
								custId: this.custInf.custId, //客户id
								custName: this.custInf.custName, //客户名称
								applyDate: this.applyShortPreviewForm.applyDate, //融资开始日期
								prepaybackDate: this.applyShortPreviewForm.prepaybackDate, //融资开始日期
								custUser: this.custInfForm.custName, //供应商对接人姓名
								custPhone: this.custInfForm.custPhone, //供应商对接人电话
								availableAmt: this.availableAmount, //可融金额
								totalFinAmount: sumNum, //累积融资金额
							};
							let that = this;
							that.saveApplyInf(params, function (data) {
								that.applyId = data && data.id ? data.id : "";
								that.custInfModel = false;
								that.isCommitApply = false;
								that.isAcceptPreview = true;
								that.isShowAcceptPreview = true;
								that.changeFromPage("applyShortPreview");
							});
						})
						.catch(() => { });
				} else {
					return false;
				}
			});
		},
		/**
         * @vuese
         * 计算融资日期
         * @arg 参数val为计算的基准日，开始日期为每月5号，结束日期为每月25号
        */
		getPaybackDate (val) {
			return getSpecifyDate(val);
        },
        /**
         * @vuese
         * 日期选择器日期范围限制
         * @arg 参数time为当前日期时间戳，dateStr已格式化日期，isBeginDate是否为开始日期
        */
		datePickerOptions (time, dateStr, isBeginDate) {
			let weeks = time.getDay(); //周几？
			let day = time.getDate(); //几号？
			if ((isBeginDate && day < 5) || day > 25) {
				return true;
			}
			if (this.whitelist.includes(dateStr)) {
				return false;
			}
			if (this.blacklist.includes(dateStr) || weeks == 6 || weeks == 0) {
				return true;
			}
			return false;
		},
	},
	computed: {
        ...mapState(["supplierApplyList", "supplyChainFinance"]),
        // 金额格式为千分位
		getFormatMoney () {
			return formatPrice(this.availableAmount);
        },
        // 格式化利率
		getRate () {
			return formatRate(this.customerRate) + "/天";
        },
        // 融资开始日期限制
		pickerOptionsBegin () {
			let dateFormat = this.$utils.dateFormat;
			let prepaybackDate = this.applyShortPreviewForm.prepaybackDate;
			//大于当前月25号 的日期不可选
			let lastDay = getSpecifyDate(24);
			let nowDate = new Date().getTime() - 24 * 60 * 60 * 1000;
			let that = this;
			return {
				disabledDate (time) {
					//开始日期不可大于融资到期日期 并且 开始日期不可大于当前日期
					if (
						(prepaybackDate && time.getTime() > prepaybackDate) ||
						time < new Date(nowDate) ||
						time.getTime() > lastDay
					) {
						return true;
					}
					return that.datePickerOptions(
						time,
						dateFormat("yyyy-MM-dd", time),
						true
					);
				},
			};
        },
        // 融资到期日限制
		pickerOptionsEnd () {
			let dateFormat = this.$utils.dateFormat;
			let applyDate = this.applyShortPreviewForm.applyDate;
			let that = this;
			//大于当前月25号 的日期不可选
			let lastDay = getSpecifyDate(25);
			return {
				disabledDate (time) {
					if (
						(applyDate && applyDate > time.getTime()) ||
						time.getTime() > lastDay ||
						time < new Date()
					) {
						return true;
					}
					return that.datePickerOptions(time, dateFormat("yyyy-MM-dd", time));
				},
			};
		},
	},
	components: {
		EmphasisTable,
		applyShortTable,
	},
};
</script>
